package com.vision.world.survey.managers;

import android.content.Context;
import android.util.Log;

import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.layers.ArcGISTiledLayer;
import com.esri.arcgisruntime.location.LocationDataSource;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.view.LocationDisplay;
import com.esri.arcgisruntime.mapping.view.MapView;

/**
 * Created by Administrator on 2017/10/10.
 */

public class MapManager {

    /**
     * device's position
     * @param mapView
     */
    public static void positionCenter(MapView mapView) {
        LocationDisplay locationDisplay = mapView.getLocationDisplay();
        locationDisplay.addDataSourceStatusChangedListener(new LocationDisplay.DataSourceStatusChangedListener() {
            @Override
            public void onStatusChanged(LocationDisplay.DataSourceStatusChangedEvent dataSourceStatusChangedEvent) {
                if (dataSourceStatusChangedEvent.getSource().getLocationDataSource().getError() == null) {
                    Log.i("error","Location Display Started=" + dataSourceStatusChangedEvent.isStarted());
                } else {
                    // Deal with problems starting the LocationDisplay...
                }
            }
        });
        locationDisplay.setAutoPanMode(LocationDisplay.AutoPanMode.RECENTER);
        if (!locationDisplay.isStarted()) {
            locationDisplay.startAsync();
        }
    }


}
